﻿using CommonUtils;
using System;

namespace ControllerGenerator.Commands
{
    class FileControllerGenerator
    {
        public static void Handler(object sender, EventArgs e)
        {
            var namespace_ = WindowsUtil.GetInput("请输入命名空间", "DefaultNamespace");
            if (namespace_.IsEmpty())
                namespace_ = "DefaultNamespace";
            var path = WindowsUtil.SelectSavePathWithName("FileController.cs");
            if (path.IsEmpty())
                return;
            var controllerCode = ResourceUtil
                     .GetText(typeof(FileControllerGenerator).Assembly, "FileController.txt")
                     .Replace("@namespace", namespace_);
            FileUtil.SaveTo(path, controllerCode);
            EditorUtil.ShowMessage("代码已生成: " + path);
        }
    }
}

